/**
 * 
 */
package xj.toolkit.ebus.unit;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author hp
 * 
 */
public class DefaultUnitSource implements UnitSource {

	private long lastModified;
	private String name;
	private String type;
	private Properties extendProperties = new Properties();
	private byte[] content;

	public void setContent(byte[] content) {
		this.content = content;
	}

	public void setLastModified(long lastModified) {
		this.lastModified = lastModified;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}
	
	public InputStream getInputStream() {
		return new ByteArrayInputStream(content);
	}

	/**
	 * @param extendProperties
	 *            the extendProperties to set
	 */
	public void setExtendProperties(Properties properties) {
		if (extendProperties != null && extendProperties.size() > 0) {
			extendProperties.putAll(properties);
		}
	}

	/**
	 * @see com.skymobi.ebus.unit.UnitSource#getTemplate()
	 */
	public String getTemplate() {
		return name;
	}

	/**
	 * @see com.skymobi.ebus.unit.UnitSource#lastModified()
	 */
	public long lastModified() {
		return lastModified;
	}

	public String getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @see xj.toolkit.ebus.unit.UnitSource#getExtendsProperties()
	 */
	@Override
	public Properties getExtendsProperties() {
		return extendProperties;
	}

}
